<style>
  #memberMain .tapList .tableClassA tbody tr {
    height: 32px;
    line-height: 32px;
  }

  #memberMain .tapList .tableClassA tbody tr td {
    padding: 0;
  }
</style>
<!--投资管理-->
<div id="memberMain" class="success">
  <div class="title"><h4>绑定交易平台</h4></div>
  <div class="tipsTop">登录交易平台获得交易平台提供的JFC地址，在下方按提示绑定</div>
  <div class="height18"></div>
  <form autocomplete="off" id="recharge-form">
    <ul class="formUl" id="userBank">
      <li class="">
        <label class="inputName">交易平台</label>
        <select name="style" id="style">
          <option value="0">选择一个交易平台</option>
          <option value="yunshu">币九区</option>
        </select>
      </li>
      <li class="">
        <label class="inputName">交易平台钱包地址</label>
        <input class="inputText cardName" name="address" value="" id="address" type="text"
               style="color: rgb(0, 0, 0);" onchange="checkAddress(this)">
        <div class="errorMessage" id="errorAdd"></div>
      </li>
      <li class="">
        <label class="inputName">交易密码</label>
        <input class="inputText" maxlength="16" minlength="6" name="payPwd" id="payPwd" type="password"
               style="color: rgb(0, 0, 0);">
      </li>
    </ul>
    <ul class="formUl">
      <li class="">
        <input class="inputBut showL inputBtnBig" type="button" value="确认" id="jax">
      </li>
    </ul>
  </form>
  <div class="height18"></div>
  <div class="tapList borderGray clearfix">
    <div class="tapTile">
      <h3 class="curr">
        <a ui-sref="transaction.buy.bind">交易平台</a>
      </h3>
    </div>
    <div class="height5"></div>
    <div class="tableClassA clearfix">
      <table cellpadding="0" cellspacing="0">
        <thead>
        <tr>
          <th>交易平台</th>
          <th>钱包地址</th>
          <th>操 作</th>
        </tr>
        </thead>
        <tbody>
        <tr class="noList showCss" ng-repeat="item in contents" data-wrType="{{item.wrType}}"
            data-wrAddr="{{item.wrAddr}}">
          <td>
            {{item.wrType}}
          </td>
          <td>
            {{item.wrAddr}}
          </td>
          <td>
            <a href="javascript:void(0)" class="del" onclick="select(this)">修改</a></td>
        </tr>
        </tbody>
      </table>
    </div>
    <div style="margin-left: 20px;">
      <div paging
           ul-class="pagination"
           page="currentPage"
           page-size="pageSize"
           total="total"
           show-prev-next="true"
           show-first-last="true"
           text-first="&laquo;"
           text-last="&raquo;"
           text-next="&rsaquo;"
           text-prev="&lsaquo;"
           text-title-page="第{page}页"
           text-title-first="首页"
           text-title-last="尾页"
           text-title-next="下一页"
           text-title-prev="上一页"
           paging-action="pageAction('Action', page,pageSize,total)">
      </div>
    </div>
  </div>
</div>
<script type="text/javascript">

  $(function () {
    $("*[name='payPwd']").focus(function () {
      $(this).attr('type', 'password');
    })
    $('#jax').bind('click', bind);

    function bind() {
      $('body').mLoading('show');
      var style = $('#style').val();
      var typename = $("#style").find("option:selected").text();

      if (!style || style <= 0) {
        $('body').mLoading('hide');
        error('请选择一个交易平台', function () {
        })
        return false;
      }
      $.post('/transaction/withdrawbind', {
        payPwd: $('#payPwd').val(),
        type: typename,
        address: $('#address').val()
      }, function (data) {
        if (data.retCode == 1) {
          $('body').mLoading('hide');
          success(data.msg, function () {
            location.reload(true);
          })
        } else {
          $('body').mLoading('hide');
          error(data.msg, function () {
          })
        }
      })
    }
  })

  function checkAddress(obj) {
    $('#errorAdd').html(' ');
    var address = $(obj).val();
    //$.post('/transaction/check-address', {address: address}, function (data) {
    //$('#errorAdd').html(data.msg);
    //})
  }

  function getTypes() {
    $.post('/transaction/getTypes', {}, function (data) {
      if (data.retCode == 1) {
        var selOpt = $("#style option");
        selOpt.remove();
        $("#style").append("<option value=\"0\">选择一个交易平台</option>");
        for (var i = 0; i < data.dataList.length; i++) {
          var opt = "<option value='" + data.dataList[i].waName + "'>" + data.dataList[i].waName + "</option>";
          //console.log(opt);
          $("#style").append(opt);
        }
      } else {

      }
    })
  }

  getTypes();

  function select(e) {
    var wrType = $(e).parent().parent().attr('data-wrType');
    var wrAddr = $(e).parent().parent().attr('data-wrAddr');
    $("#address").val(wrAddr);
    sltSelect(wrType);
  }

  function sltSelect(txt) {
    var se = document.getElementById("style");
    var os = se.getElementsByTagName("option");
    for (var i = 0; i < os.length; i++) {
      if (os[i].innerHTML == txt) {

        os[i].selected = true;
        break;
      }
    }
  }
</script>

